<?php defined('SYSPATH') or die('No direct script access.');

	class Controller_Period extends Controller{
			
			public function action_index(){
							
				$view = View::factory("page");
				$view->page_title = "Periodos de Muestreo";
				$view->page_icon = "media/img/layout/frequency32.png";
								
				$grid = new Jqgrid("samplingperiod", Helper_Service::factory("samplingperiod"));
				$view->page_content = $grid->render("jqgrid/config/samplingperiod"); 
				
				$this->request->response = $view->render();	
			}
			
			public function action_list(){
				$grid = new Jqgrid("samplingperiod", Helper_Service::factory("samplingperiod"));
				
				$criteria = new Jqgrid_Criteria();
				$criteria->page = $_POST['page'];
				$criteria->limit = $_POST['rows'];
				$criteria->sidx = $_POST['sidx'];
				$criteria->sord = $_POST['sord'];
				
				if (isset($_POST['_search'])){
					if (($search = $_POST['_search']) == "true"){
						$criteria->isSearch = true;
						$criteria->searchField = $_POST['searchField'];
						$criteria->searchOper = $_POST['searchOper'];
			 			$criteria->searchString = $_POST['searchString'];
					}
				}
				
				$this->request->response = $grid->getList($criteria);
			}
			
			public function action_save(){
				$grid = new Jqgrid("samplingperiod", Helper_Service::factory("samplingperiod"));
				$this->request->response = $grid->save($_POST['oper'],$_POST);
			}
			
		}
// End Period ?>
